package zuoye;

public class Text1 {
    public static void main(String args[]) {
        SeqStack<zuoye.Student> b = new SeqStack<>();
        b.push(new Student("小红", 15));
        b.push(new Student("小绿", 25));
        b.push(new Student("小蓝", 5));
        b.push(new Student("小紫", 11));
        b.push(new Student("小粉", 35));
        b.display();

        SeqList student = new SeqList();
        int count = b.getCount();

        for (int i = 0; i < count; i++) {

            student.insert((Student) b.top());
            b.pop();
        }
        student.display();
        System.out.println("--------------------------------------------");
        System.out.println("完成顺序栈的逆转，下面开始到链表的由小到大");
        System.out.println();

        //创建顺序表
        SeqList student2 = new SeqList();
        student2.insert(new Student("小红", 15));
        student2.insert(new Student("小绿", 25));
        student2.insert(new Student("小蓝", 5));
        student2.insert(new Student("小紫", 11));
        student2.insert(new Student("小粉", 35));

        //创建单链表
        NodeList stu2 = new NodeList();

        int stu2Count = student2.getCount();
        for (int a = 0; a < stu2Count; a++) {
            stu2.insertSize(student2.top(a));
        }
        stu2.display();

        //输入到链栈
        StackList stu = new StackList();
        for(int i=0;i<stu2Count;i++){
            stu.push(stu2.pop());
        }

        stu.display();

        //二进制

        /*int x =100;
        String result = getBinary(x);
        System.out.println("二进制"+result);

        String hex = getHexadecimal(x);
        System.out.println("十六进制"+hex);



    }

    private static String getHexadecimal(int x) {
        SeqStack seqStack = new SeqStack();
        while(x!=0){
            int mod = x%16;
                if(mod<10){
                    seqStack.push(String.valueOf(mod));
                }
                else
                {
                    switch (mod){
                        case 10:
                            seqStack.push("A");
                            break;
                        case 11:
                            seqStack.push("B");
                            break;
                        case 12:
                            seqStack.push("C");
                            break;
                        case 13:
                            seqStack.push("D");
                            break;
                        case 14:
                            seqStack.push("E");
                            break;
                        case 15:
                            seqStack.push("F");
                            break;

                    }


            }
            x=x/16;
        }
        StringBuffer buffer = new StringBuffer();
        while(!seqStack.isEmpty()){
            buffer.append(seqStack.top());
            seqStack.pop();
        }

        return  buffer.toString();
    }

    private static String getBinary(int x) {
        SeqStack seqStack = new SeqStack();
        while(x!=0){
            seqStack.push(x%2);
            x=x/2;
        }
     StringBuffer buffer = new StringBuffer();
        while(!seqStack.isEmpty()){
            buffer.append(seqStack.top());
            seqStack.pop();
        }

        return  buffer.toString();
    }
*/
    }
}
